home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / What's New? / Development Kits / Display Manager SDK v1.1 / Display Manager Sample Code / Play Video Sample / PlayVideo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-05  |  5.6 KB  |  136 lines  |  [TEXT/MMCC]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    MacOS™ Sample Code
  4. #    
  5. #    Written by: Eric Anderson
  6. #     EWorld/AppleLink: ERIC3
  7. #     AOL: ERICTHREE
  8. #
  9. #    Display Manager sample code
  10. #
  11. #    PlayVideo
  12. #
  13. #    PlayVideo.c    -    C Source
  14. #
  15. #    Copyright © 1995 Apple Computer, Inc.
  16. #    All rights reserved.
  17. #
  18. #    5/31/95        ewa        Added RVGetCurrentVideoSetting and RVConfirmVideoRequest routines
  19. #                        to make it easy to revert back to where you came from and to give
  20. #                        the user a chance to confirm the new setting if the new mode was
  21. #                        valid (ie: the card supports it) but not safe (the monitor may not).
  22. #
  23. #    Components:    PlayVideo.c            
  24. #                RequestVideo.c        
  25. #                RequestVideo.h        
  26. #
  27. #    PlayVideo demonstrates the usage of the RequestVideo sample library
  28. #    to make Display Manager calls. With PlayVideo, you can explore the
  29. #    RequestVideo API by changing bit depth and screen resolution on
  30. #    multisync displays. The purpose of this code is to provide a sample of
  31. #    how developers can change the bit depth and timing of multisync
  32. #    displays under their own control. Game developers should love this!
  33. #    
  34. #    After requesting a desired bit depth, horizontal, and vertical resolutions
  35. #    using the RVRequestVideoSetting() call, we then make the RVSetVideoRequest()
  36. #    call to do the deed. At exit, we call RVSetVideoAsScreenPrefs() to force the
  37. #    world to look like that described in the screen prefs.
  38. #
  39. #    It is a good idea to reset the screen(s) to the original setting before exit
  40. #    since the call to RVSetVideoAsScreenPrefs() may not do the right thing under
  41. #    Display Manager 1.0 with certain video drivers.
  42. #
  43. ------------------------------------------------------------------------------*/
  44.  
  45. #include "RequestVideo.h"
  46. #include <Memory.h>
  47. #include <StdIO.h>
  48. #include <stdlib.h>
  49.  
  50. // routine defines
  51. unsigned long GetUserInputData (void);
  52.  
  53. // routine implementations
  54. void main(void)
  55. {
  56.     VideoRequestRec requestRec;
  57.     VideoRequestRec originalRec;
  58.     short        currentDepth;
  59.     short        currentHorizontal;
  60.     short        currentVertical;
  61.  
  62.     MaxApplZone();
  63.  
  64.     printf("Welcome to •Guess That Video•\n");
  65.     printf("\nIMPORTANT: WARNING WHEN CHANGING THE SCREEN RESOLUTION\n");
  66.     printf("IMPORTANT:       IN A MULTI-MONITOR ENVIRONMENT\n");
  67.     printf("IMPORTANT: Monitor gravitation (repositioning) is not suported under\n");
  68.     printf("IMPORTANT: Display Manager 1.0, and there is not currently any code\n");
  69.     printf("IMPORTANT: written in this sample library to provide even minimal\n");
  70.     printf("IMPORTANT: gravitate functionality.\n");
  71.     printf("IMPORTANT: Currently, changing the video settings on\n");
  72.     printf("IMPORTANT: multi-monitor systems under the Display Manager 1.0.\n");
  73.     printf("IMPORTANT: will result in only the bit depth being changed.\n");
  74.  
  75.     do
  76.     {
  77.         requestRec.screenDevice = nil;        // any screen
  78.         printf("\nRequested bit depth (999 to end the game):");
  79.         requestRec.reqBitDepth = GetUserInputData ();        // bit depth request
  80.         if (requestRec.reqBitDepth != 999)
  81.         {
  82.             // fill in the request record
  83.             printf("Requested horizontal resolution:");
  84.             requestRec.reqHorizontal = GetUserInputData ();;    // H request
  85.             printf("Requested vertical resolution:");
  86.             requestRec.reqVertical = GetUserInputData ();;        // V request
  87.             requestRec.displayMode = nil;                        // must init to nil
  88.             requestRec.depthMode = nil;                            // must init to nil
  89.             requestRec.requestFlags = 1<<kAllValidModesBit;                        // give me the HxV over bit depth, and only safe video modes
  90.  
  91.             // make the request and set it if we have one....
  92.             RVRequestVideoSetting(&requestRec);
  93.  
  94.             if (requestRec.screenDevice != nil)        // make sure we found a device...possible if there are no "safe" video modes
  95.             {
  96.                 // Get current setting
  97.                 originalRec.screenDevice = requestRec.screenDevice;        // this screen
  98.                 RVGetCurrentVideoSetting(&originalRec);
  99.                 
  100.                 // print out the current info
  101.                 currentDepth = (*(*(requestRec.screenDevice))->gdPMap)->pixelSize;
  102.                 currentHorizontal = abs ((*(*(requestRec.screenDevice))->gdPMap)->bounds.right - (*(*(requestRec.screenDevice))->gdPMap)->bounds.left);
  103.                 currentVertical = abs ((*(*(requestRec.screenDevice))->gdPMap)->bounds.bottom - (*(*(requestRec.screenDevice))->gdPMap)->bounds.top);
  104.                 printf ("\n");
  105.                 printf ("Info for GDevice at: %d\n", requestRec.screenDevice);
  106.                 printf ("Original depth:%d, horizontal:%d, vertical:%d\n", currentDepth, currentHorizontal, currentVertical);
  107.                 printf ("Requested depth:%d, horizontal:%d, vertical:%d\n", requestRec.reqBitDepth, requestRec.reqHorizontal, requestRec.reqVertical);
  108.                 printf ("Setting depth:%d, horizontal:%d, vertical:%d\n", requestRec.availBitDepth, requestRec.availHorizontal, requestRec.availVertical);
  109.             
  110.                 // Set/Confirm/Reset the request
  111.                 RVSetVideoRequest (&requestRec);
  112.                 if (noErr != RVConfirmVideoRequest (&requestRec))
  113.                     RVSetVideoRequest (&originalRec);
  114.                 
  115.                 // print out the new info            
  116.                 currentDepth = (*(*(requestRec.screenDevice))->gdPMap)->pixelSize;
  117.                 currentHorizontal = abs ((*(*(requestRec.screenDevice))->gdPMap)->bounds.right - (*(*(requestRec.screenDevice))->gdPMap)->bounds.left);
  118.                 currentVertical = abs ((*(*(requestRec.screenDevice))->gdPMap)->bounds.bottom - (*(*(requestRec.screenDevice))->gdPMap)->bounds.top);
  119.                 printf ("New depth:%d, horizontal:%d, vertical:%d\n", currentDepth, currentHorizontal, currentVertical);
  120.             }
  121.         }
  122.     } while (requestRec.reqBitDepth != 999);    // our clue to bail
  123.     printf("\nThank you for playing •Guess That Video•\n");
  124.  
  125.     // attempt to reset the world to screen prefs setting (may not do anything with old video drivers)
  126.     RVSetVideoAsScreenPrefs ();
  127. }
  128.  
  129. // Get user input of a number
  130. unsigned long GetUserInputData (void)
  131. {
  132.     long    tempLong = 0;                
  133.     do scanf ("%ld", &tempLong); while (tempLong == 0);        
  134.     return (tempLong);
  135. }
  136.